

---------------
Water_life Api:
---------------



useful constants:
------------------

water_life.abr = minetest.get_mapgen_setting('active_block_range') or 2
water_life.abo = minetest.get_mapgen_setting('active_object_send_range_blocks') or 3
water_life.maxwhales = 1 
water_life.maxsharks = water_life.abo/2
water_life.maxmobs = 30
water_life.catchBA = String containing name of item to capture big animals (for example "mobs:lasso" )


helper functions:
-----------------



##########################
water_life.random(min,max)
##########################
uses minetest PcgRandom generator for better random numbers
https://en.wikipedia.org/wiki/Permuted_congruential_generator
a bit slower, but better numbers than math.random

water_life.random() 			will return a float between 0 and 1
water_life.random(10)			will return integer number between 1 and 10
water_life.random(50,100)		will return integer number betwwen 50 and 100



###############################
 water_life_get_biome_data(pos)
###############################
gets biome data at >pos< and return a table or nil

biome.id	= biome id number
biome.name	= biome name
biome.temp	= temperature in celsius (integer rounded)
biome.humid	= humidity in % (float rounded, two decimal places)
	

################################
 water_life.water_depth(pos,max)
 ###############################
 
 will try to find a liquid surface at position pos, give up after #max nodes
 
 returns depth,type,surface or nil:
 
 surface 		= table, position of water surface node
 depth		= float, liquid depth at that position
 type		= string,  name of liquid source node found
 
 
 
#####################################
water_life.temp_show(pos,time,pillar)
#####################################
(convenience function for older people like me :D )

shows a marker entity at >pos< for >time< seconds.
if pillar set, >pillar< nodes high



########################
water_life.leftorright()
########################

returns true with a possibility of 50% else returns false



####################################
water_life.register_shark_food(name)
####################################

register enitiy "name" as shark food. Will be attacked by sharks if in water and in sight



##########################################
water_life.count_objects(pos,radius)
##########################################

if radius is nil radius will be the active_object_send_range_blocks * 16
counts objects around >pos< with >radius< in nodes and returns a table:


table.all       -   total number of all objects
table["objectname"] = nil or number of found objects



#############################
water_life.handle_drops(self)
#############################

call this on death of an entity and define drops in entity definition like this:
chances are in 100/x. So chance =1 means 100%, 2 = 50%, 3 = 33 1/3 %, ...

drops = {
		{name = "default:diamond", chance = 5, min = 1, max = 5,},		
		{name = "water_life:meat_raw", chance = 2, min = 1, max = 5,},
	},
	


#########################################	
water_life.get_yaw_to_object(self,tgtobj)
#########################################

returns 2D angle in rad tgtobj seen from self



##########################################
water_life.find_collision(pos1,pos2,water)
##########################################

throws a raycast from pos1 to pos2

if water is true then water is handled as obstacle
returns distance to obstacle in integer or nil
if nothing found



#########################################
water_life.radar(pos, yaw, radius, water)
#########################################

radar function which will give you back 6 integers:
    left, right, up, down, under, above

    pos:        this should be the pos of the entity
    yaw:        yaw of the entity 
    radius:     radius from pos to scan for obstacles
    water:      if true waternodes are obstacles
    
    
(in general higher values mean more and nearer obstacles)


calculation for left and right value:


                            left                                right

                +44     +33     +22     +11     0       -11     -22     -33     -44       yaw add/subtract in degrees
    
    pos.y+6     1       2       3       4       5       4       3       2       1
    
    pos.y+4     1       2       3       4       5       4       3       2       1
    
    pos.y+2     1       2       3       4       5       4       3       2       1
    
    pos.y       1       2       3       4       5       4       3       2       1
    
    
    if found an obstacle at a position the value of above table is added to right or
    left value. Position at 0 is added to left and right value
    
    pos is the position in yaw +/- degrees in distance of radius in front of the entiy
    
    that means, the higher values of left and/or right, the more obstacles found near to
    center position in distance of radius in front of the entity.

    
    
    
calculation of up and down value:


                    +33     +22     +11     0       -11     -22     -33
      
        pos.y+-4    0       1       2       3       2       1       0
        
        pos.y+-3    1       2       3       4       3       2       1
        
        pos.y+-2    2       3       4       5       4       3       2   
        
        pos.y+-1    3       4       5       6       5       4       3
        
        pos.y+-0    4       5       6       7       6       5       4
        
        if found an obstacle at a position the value from above table is
        multiplied by (distance to obstacle/radius) *2. That means if an
        obstacle is right in front the table value is doubled.
        
        
        
calculation of under value:

    this is the distance between entity pos.y value and the ground
    
    
calculation of above value:

    this is the distance between entity pos.y value and ceiling above
    
    
    
    
    
    



HQ Behaviors:
-----------

#################################################
water_life.hq_swimto(self,prty,speed,node,tgtpos)
#################################################

mob will swim to given node which must be in its view_range
node can be a string or a table of string
OR
if tgtpos is set it will swim there, node will be ignored then
returns if distance <= 1 node



#########################################################
water_life.hq_swimfrom(self,prty,tgtobj,speed,outofsight)
#########################################################

mob will turn 180 degrees away from target and try to escape until target is out of sight (if nil viewrange + 50%)



#################################################
water_life.big_hq_aqua_turn(self,prty,tyaw,speed)
#################################################

will turn mob with large collisionbox to tyaw with speed



#########################################
water_life.big_aqua_roam(self,prty,speed)
#########################################

mob with large collisionbox will roam the waters with given speed.
A bit like mobkit.hq_aqua_roam with less turns



Chat commands:
----------------


########
wl_bdata
########

needs server privs, shows biome id,name,temperature in celsius and humidity at player position


##########
wl_version
##########

will print out water_life version number, needs server priv


#######
wl_kill <mobname>
#######

kills all <mobname> in abr

